import React, {Component} from "react";
import {ListView, Text, TouchableOpacity, View} from "react-native";
import chjStyle from "../../../CustomStyle";
import ModuleCommonHeader from "../../module/ModuleCommonHeader";

export default class CarModelSelection extends Component{

  constructor(props)
  {
    super(props);
    const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});

    this.state = {
        dataSource: ds.cloneWithRows(this.props.data)
    };
  }

  componentDidMount()
  {

  }

  render() {
    return (
      <View
      style={chjStyle.mainContainer}>
        <ModuleCommonHeader title='选择车辆型号'/>
        <ListView
        initialListSize={1}
        style={chjStyle.recordContainer}
        dataSource={this.state.dataSource}
        renderRow={this.renderRow.bind(this)}
        />
      </View>
    );
  }

  renderRow(rowData){
    return (
      <TouchableOpacity style={chjStyle.textItem} onPress={
        ()=>{
            this.props.onSelectedListener(rowData);
          // this.props.navigator.pop();
        }
      }>
          <Text style={chjStyle.textItemText}>{rowData.name || rowData}</Text>
      </TouchableOpacity>
    );
  }
}
